import { Component, OnInit, Input } from '@angular/core';
import { HttpService } from '../../shared/service/http.service';
import { AppGlobalService } from '../../shared/service/app-global.service';
import { filter } from 'rxjs/operators';
@Component({
  selector: 'app-recommand-by-customer',
  templateUrl: './recommand-by-customer.component.html',
  styleUrls: ['./recommand-by-customer.component.scss'],
})
export class RecommandByCustomerComponent implements OnInit {

  @Input() tagData: any;
  keyword: any;
  searchBtnColor = {};
  constructor(private appGlobalService: AppGlobalService, private httpService: HttpService) { }
  ngOnInit() {
    this.keyword = '';
  }
  search() {
    if (this.keyword !== '') {
      try {
        // const value = this.keyword;
        if (this.tagData.data.link.params) {
          // const keys = Object.keys(this.tagData.data.link.params);
          // this.tagData.data.link.params[keys[0]] = value;
          if (this.tagData.data.keyword) {
            const filterObj = {};
            filterObj[this.tagData.data.keyword] = this.keyword;
            // tslint:disable-next-line:no-string-literal
            this.tagData.data.link.params['filter'] = filterObj;
          }
        }
        const params = {
          pageId: this.tagData.data.link.target,
          params: this.tagData.data.link.params,
          sessionId: localStorage.getItem("sessionId")
        };
        this.appGlobalService.goToForward(params);
      } catch (error) {
        console.log('error----->' + JSON.stringify(error));
      }

    }
  }
  ionBlur() { }
  focusInput() { }
  searchChange() { }
  press(e?) { }
}

